{include file="public/_header"}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form-item">
                <div class="layui-inline">&emsp;
                    <button id="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;
                </div>
            </div>
            <table id="tableContainer" lay-filter="tableContainer"></table>
        </div>
    </div>
</div>
{include file="public/_footer"}
<script>
    layui.use(['layer', 'form', 'admin', 'table', 'util','xmSelect','element'],function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var table = layui.table;

        initTable();
        function initTable() {
            var pcode = $('#pcode').val();
            var url = "{:url('getData')}";
            var insTb = table.render({
                elem: '#tableContainer',
                url: url,
                // toolbar: ['<p>',
                //     '<button lay-event="add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>添加</button>&nbsp;',
                //     '</p>'].join(''),
                cellMinWidth: 100,
                cols : [[
                    {field: 'id', title: 'ID'},
                    {field: 'title', title: '标题'},
                    {field: 'type', title: '类型'},
                    {field: 'value', title: '类型值'},
                    {title: '操作', toolbar: '#barDemo', align: 'center', width: 200, minWidth: 200}
                ]]
            });
        }

        table.on('tool(tableContainer)', function (obj) {
            if (obj.event === 'edit') { // 修改
                window.location.href = 'edit.html?id=' + obj.data.id;
            }
        });

        $('#add').click(function () {
            window.location.href = 'add.html';
        });
    });
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
</script>
</body>
</html>